package o;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.base.bean.DependAppBean;
import com.huawei.appgallery.foundation.ui.framework.widget.dialog.dialogactivity.DialogActivity.a;
import java.util.ArrayList;
import java.util.List;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class dju {
    private b ˋ;

    public interface b {
        void ˎ();

        void ॱ(BaseDistCardBean baseDistCardBean, boolean z);
    }

    public void ˏ(b bVar) {
        this.ˋ = bVar;
    }

    public void ˊ(Context context, BaseDistCardBean baseDistCardBean) {
        if (ॱ(baseDistCardBean)) {
            ॱ(context, baseDistCardBean);
        } else if (this.ˋ != null) {
            this.ˋ.ॱ(baseDistCardBean, false);
        }
    }

    private void ॱ(Context context, final BaseDistCardBean baseDistCardBean) {
        new a(context, "DependsAppDialog").ˎ(ˊ(context, baseDistCardBean.ˊˊ(), baseDistCardBean.v_()), null).ˋ(-1, n.ٴ).ˋ(-2, n.ˊˈ).ˏ(new ckh.a(this) {
            final /* synthetic */ dju ˏ;

            public void ˏ(AlertDialog alertDialog, a aVar, int i) {
                if (this.ˏ.ˋ == null) {
                    return;
                }
                if (-1 == i) {
                    this.ˏ.ˋ.ॱ(baseDistCardBean, true);
                } else if (-2 == i) {
                    this.ˏ.ˋ.ˎ();
                }
            }
        }).ˏ(new OnCancelListener(this) {
            final /* synthetic */ dju ˊ;

            {
                this.ˊ = r1;
            }

            public void onCancel(DialogInterface dialogInterface) {
                if (this.ˊ.ˋ != null) {
                    this.ˊ.ˋ.ˎ();
                }
            }
        }).ˎ();
    }

    private View ˊ(Context context, List<DependAppBean> list, String str) {
        LayoutInflater from = LayoutInflater.from(context);
        View inflate = from.inflate(h.ॱˑ, null);
        TextView textView = (TextView) inflate.findViewById(j.ˋʾ);
        LinearLayout linearLayout = (LinearLayout) inflate.findViewById(j.ˊᐩ);
        textView.setText(context.getString(n.ᴵ, new Object[]{str}));
        ScrollView scrollView = (ScrollView) inflate.findViewById(j.ˋʿ);
        int ˎ = ewb.ˎ((Activity) context);
        scrollView.setPadding(ˎ, 0, ˎ, 0);
        textView.setPadding(ˎ, ˎ, ˎ, 0);
        for (DependAppBean dependAppBean : list) {
            View inflate2 = from.inflate(h.ॱˍ, null);
            ((TextView) inflate2.findViewById(j.ॱʼ)).setText(dependAppBean.name_);
            linearLayout.addView(inflate2);
        }
        return inflate;
    }

    private boolean ॱ(BaseDistCardBean baseDistCardBean) {
        List<DependAppBean> ˊˊ = baseDistCardBean.ˊˊ();
        if (!(ˊˊ == null || CollectCheck.isEmpty((List) ˊˊ))) {
            List<DependAppBean> arrayList = new ArrayList();
            for (DependAppBean dependAppBean : ˊˊ) {
                if (ˊ(dependAppBean)) {
                    arrayList.add(dependAppBean);
                }
            }
            for (DependAppBean dependAppBean2 : arrayList) {
                ˊˊ.remove(dependAppBean2);
            }
            if (!CollectCheck.isEmpty((List) ˊˊ)) {
                return true;
            }
        }
        return false;
    }

    private boolean ˊ(DependAppBean dependAppBean) {
        if (TextUtils.isEmpty(dependAppBean.package_)) {
            return false;
        }
        return ((cdg) cdb.ॱ(cdg.class)).ˎ(dependAppBean.package_, dependAppBean.minVersionCode_);
    }
}
